import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'demo_logic.dart';

class Demo2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //读取数据vm
    DemoLogic logic = Get.find();
    return Scaffold(
        // Use Obx(()=> to update Text() whenever count is changed.
        appBar: AppBar(
            title: Obx(() => Text("Clicks: ${logic.count}   "
                "${logic.text}"))),
        // Replace the 8 lines Navigator.push by a simple Get.to(). You don't need context
        body: Center(
            child: Column(children: [


          ElevatedButton(
              child: Text("设置count"),
              onPressed: () => {logic.count.value = 444444}),
          ElevatedButton(
              child: Text("设置文本"),
              onPressed: () => {logic.text.value = "nnnnnn"})
        ])),
        floatingActionButton: FloatingActionButton(
            child: Icon(Icons.add), onPressed: logic.increment));
  }
}
